{assign var="title" value="Orders"}
{include file="header.tpl.html"}

<div class="content">
	
	<div class="toolbar">
		<ul class="buttons">
			<li><a href="#" class="save"><span style="background-image: url(/admin/backend/resources/images/icons/accept.png)">Save</span></a></li>
		</ul>
	</div>
	
	<div class="content-below-toolbar">
		
		<div class="inner-content">
			
			<div class="breadcrumb">
				<a href="../../">Orders</a>
				#{$order.id|str_pad:6:0:$smarty.const.STR_PAD_LEFT}
			</div>
			
			<div style="float:left; margin-right: 15px">
				
				<h2>Order #{$order.id}</h2>
				
				<table class="table data top">
					<tr>
						<td class="narrow-as-possible">Date &amp; time:</td>
						<td>{$order.created|strtotime|date:'M d, Y (H:i:s)'}</td>
					</tr>
					<tr class="alt">
						<td class="narrow-as-possible">IP address:</td>
						<td>{$order.ip_address}</td>
					</tr>
					<tr>
						<td class="narrow-as-possible">Origin:</td>
						<td>{$order.ip_address_country}</td>
					</tr>
					<tr class="alt">
						<td class="narrow-as-possible">Customer:</td>
						<td>
							{$order.billing_title|escape:"htmlall":"UTF-8"}{$order.billing_first_name|escape:"htmlall":"UTF-8"} {$order.billing_last_name|escape:"htmlall":"UTF-8"}<br />
							{$order.billing_address_1|escape:"htmlall":"UTF-8"}<br />
							{if $order.billing_address_2}{$order.billing_address_2|escape:"htmlall":"UTF-8"}<br />{/if}
							{$order.billing_city|escape:"htmlall":"UTF-8"}<br />
							{if $order.billing_state}{$order.billing_state|escape:"htmlall":"UTF-8"} {/if}
							{$order.billing_postcode|escape:"htmlall":"UTF-8"}<br />
							<span class="{if $order.billing_country_id != $order.ip_address_country_id}warn{/if}">{$order.billing_country|escape:"htmlall":"UTF-8"}</span><br />
							{if $order.billing_phone}
								Tel. {$order.billing_phone}
							{/if}
						</td>
					</tr>
					<tr>
						<td class="narrow-as-possible">Email:</td>
						<td><a href="mailto:{$order.email}?subject=Your%20order%20({$order.id})">{$order.email}</a></td>
					</tr>
					
					<tr class="alt">
						<td class="narrow-as-possible">Price:</td>
						<td>
							<table class="compact">
								<tr>
									<td class="narrow-as-possible">Subtotal:</td>
									<td class="right">{$order.price_excl_vat|format_price}</td>
								</tr>

								<tr>
									<td class="narrow-as-possible">Delivery:</td>
									<td class="right">{$order.delivery_price_excl_vat|format_price}</td>
								</tr>

								<tr>
									<td class="narrow-as-possible">VAT:</td>
									<td class="right">{$order.vat+$order.delivery.vat|format_price}</td>
								</tr>

								<tr>
									<td class="narrow-as-possible">Total:</td>
									<td class="right">{$order.total|format_price}</td>
								</tr>
							</table>
						</td>
					</tr>
					
					<tr>
						<td class="narrow-as-possible">Status:</td>
						<td class="status">
							{include file="shop/orders/_edit_status.tpl.html"}
						</td>
					</tr>
				</table>
				
				
				<h3>Transactions</h3>
				<table class="table data">
					<tr>
						<th>Method</th>
						<th>Time</th>
						<th class="right">Amount</th>
						<th>Tx. ID</th>
						<th>Auth. no</th>
						<th class="center">CV2</th>
						<th class="center">Address</th>
						<th class="center">Postcode</th>
						<th class="center">3D Secure</th>
					</tr>
					
					{foreach from="`$order.transactions`" item="transaction"}
						<tr class="{cycle values=",alt" name="transactions"}">
							<td>
								{if $transaction.method == 'sagepay'}
									<img src="/admin/backend/resources/images/shop/sagepay.png" alt="SagePay" title="SagePay" />
								{elseif $transaction.method == 'paypal'}
									<img src="/admin/backend/resources/images/shop/paypal.png" alt="PayPal" title="PayPal" />
								{/if}
							</td>
							<td>{$transaction.timestamp|strtotime|date:'M d, Y (H:i:s)'}</td>
							<td class="right">{$transaction.amount}</td>
							<td>
								{if $transaction.method == 'sagepay'}
									{$transaction.sagepay_VPSTxId}
								{/if}
							<td>
								{if $transaction.method == 'sagepay'}
									{$transaction.sagepay_TxAuthNo}
								{/if}
							</td>
							<td class="center narrow-as-possible">
								{if $transaction.sagepay_CV2Result=='MATCHED'}
									<img src="/admin/backend/resources/images/icons/accept.png" alt="MATCHED" title="MATCHED" />
								{elseif $transaction.sagepay_CV2Result=='NOTMATCHED'}
									<img src="/admin/backend/resources/images/icons/decline.png" alt="NOTMATCHED" title="NOTMATCHED" />
								{else}
									<img src="/admin/backend/resources/images/icons/gs/stop.png" alt="{$transaction.sagepay_CV2Result}" title="{$transaction.sagepay_CV2Result}" />
								{/if}
							</td>
							<td class="center narrow-as-possible">
								{if $transaction.sagepay_AddressResult=='MATCHED'}
									<img src="/admin/backend/resources/images/icons/accept.png" alt="MATCHED" title="MATCHED" />
								{elseif $transaction.sagepay_AddressResult=='NOTMATCHED'}
									<img src="/admin/backend/resources/images/icons/decline.png" alt="NOTMATCHED" title="NOTMATCHED" />
								{else}
									<img src="/admin/backend/resources/images/icons/gs/stop.png" alt="{$transaction.sagepay_AddressResult}" title="{$transaction.sagepay_AddressResult}" />
								{/if}
							</td>
							<td class="center narrow-as-possible">
								{if $transaction.sagepay_PostCodeResult=='MATCHED'}
									<img src="/admin/backend/resources/images/icons/accept.png" alt="MATCHED" title="MATCHED" />
								{elseif $transaction.sagepay_PostCodeResult=='NOTMATCHED'}
									<img src="/admin/backend/resources/images/icons/decline.png" alt="NOTMATCHED" title="NOTMATCHED" />
								{else}
									<img src="/admin/backend/resources/images/icons/gs/stop.png" alt="{$transaction.sagepay_PostCodeResult}" title="{$transaction.sagepay_PostCodeResult}" />
								{/if}
							</td>
							<td class="center narrow-as-possible">
								{if $transaction.sagepay_3DSecureStatus=='OK'}
									<img src="/admin/backend/resources/images/icons/accept.png" alt="MATCHED" title="MATCHED" />
								{elseif $transaction.sagepay_3DSecureStatus=='NOTMATCHED'}
									<img src="/admin/backend/resources/images/icons/decline.png" alt="NOTMATCHED" title="NOTMATCHED" />
								{else}
									<img src="/admin/backend/resources/images/icons/gs/stop.png" alt="{$transaction.sagepay_3DSecureStatus}" title="{$transaction.sagepay_3DSecureStatus}" />
								{/if}
							</td>
							
							
						</tr>
					{/foreach}
				</table>
				
				
				
				
				<h3>Deliveries</h3>
				
				{foreach from="`$order.deliveries`" item="delivery"}
				{cycle values=",alt" name="lines" reset=true print=false advance=false}
				<table class="deliveries" id="delivery_{$delivery.id}">
					<tr>
						<td class="address">
							{$delivery.delivery_title|escape:"htmlall":"UTF-8"}{$delivery.delivery_first_name|escape:"htmlall":"UTF-8"} {$delivery.delivery_last_name|escape:"htmlall":"UTF-8"}<br />
							{$delivery.delivery_address_1|escape:"htmlall":"UTF-8"}<br />
							{if $delivery.delivery_address_2}{$delivery.delivery_address_2|escape:"htmlall":"UTF-8"}<br />{/if}
							{$delivery.delivery_city|escape:"htmlall":"UTF-8"}<br />
							{if $delivery.delivery_state}{$delivery.delivery_state|escape:"htmlall":"UTF-8"}{/if}
							{$delivery.delivery_postcode|escape:"htmlall":"UTF-8"}<br />
							<span class="{if $delivery.delivery_country_id != $order.ip_address_country_id}warn{/if}">{$delivery.delivery_country|escape:"htmlall":"UTF-8"}</span><br />
							{if $delivery.delivery_phone}
								Tel. {$delivery.delivery_phone}<br />
							{/if}
							<br />
							<strong>{$delivery.delivery_method|escape:"htmlall":"UTF-8"} ({$delivery.price_excl_vat}{if $delivery.vat} + {$delivery.vat}{/if})</strong><br />
							{if $delivery.tracking_url}
								<div class="tracking-reference">
									{include file="shop/orders/_edit_tracking_reference.tpl.html"}
								</div>
							{/if}
							<span id="dispatched_{$delivery.id}">
								{include file="shop/orders/_edit_dispatched.tpl.html"}
							</span>
							
						</td>
						
						<td>
							<table class="table data">
								<tr>
									<th class="col_delivery_code">Code</th>
									<th class="col_delivery_title">Title</th>
									<th class="col_delivery_price right">Price</th>
									<th class="col_delivery_vat right">VAT</th>
									<th class="col_delivery_quantity center">Quantity</th>
									<th class="narrow-as-possible"></th>
								</tr>
								{foreach from="`$delivery.lines`" item="line"}
									<tr class="{cycle values=",alt" name="lines" advance=false}">
										<td>{if $line.subcode}{$line.subcode|escape:"htmlall":"UTF-8"}{else}{$line.code|escape:"htmlall":"UTF-8"}{/if}</td>
										<td>{$line.title|escape:"htmlall":"UTF-8"}</td>
										<td class="right">{$line.price_excl_vat|escape:"htmlall":"UTF-8"}</td>
										<td class="right">{$line.vat|escape:"htmlall":"UTF-8"}</td>
										<td class="center">{$line.quantity}</td>
										<td>{if $line.simpleattributes|@count}<a href="#" class="show-attributes"><img src="/admin/backend/resources/images/icons/table.png" alt="Show/hide attributes" title="Show/hide attributes" /></a>{/if}</td>
									</tr>
									{if $line.simpleattributes|@count}
										<tr class="{cycle values=",alt" name="lines" advance=true}" style="display:none">
											<td colspan="6">
												<table class="table data inner">
													<tr>
														<th>Title</th>
														<th>Value</th>
													</tr>
													{cycle values=",alt" name="simpleattributes" reset=true print=false advance=false}
													{foreach from="`$line.simpleattributes`" item="simpleattribute"}
														<tr class="{cycle values=",alt" name="simpleattributes"}">
															<td>{$simpleattribute.title|escape:"htmlall":"UTF-8"}</td>
															<td>{$simpleattribute.value|nl2br|escape:"htmall":"UTF-8"}</td>
														</tr>
													{/foreach}
												</table>
											</td>
										</tr>
									{/if}
								{/foreach}
							</table>
						</td>
					</tr>
				</table>
				{/foreach}
				
				
			</div>
			
		</div>
		
	</div>
	
</div>

{include file="footer.tpl.html"}